<template>
  <el-dialog title="销售业务提成管理" :visible.sync="dialogVisible" width="900px" :close-on-click-modal="false"
    :modal-append-to-body="false" v-drag2anywhere>
    <el-form :model="formData" label-width="90px" size="mini">
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="订单号:">
            {{formData.ordercode==''?'无':formData.ordercode}}
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="下单渠道:">
              <span>{{formData.platform}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="订单总额:">
            {{parseFloat(formData.sum_order).toFixed(2)}}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="8">
          <el-form-item label="客户名称:">
             {{formData.client}}
          </el-form-item>
        </el-col>
        <el-col :span="16">
          <el-form-item label="客户单位:">
             {{formData.clientname}}
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="业务员:">
             <span style="font-weight: bolder;">{{formData.saleman}}</span>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="提成金额:">
            <el-input v-model="formData.commission_rmb" placeholder="提成金额"></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="结算状态:">
            <el-select v-model="formData.commission_status" placeholder="请选择结算状态">
              <el-option label="未结算" value="0"></el-option>
              <el-option label="已结算" value="1"></el-option>
            </el-select>
           </el-form-item>
        </el-col>
        <el-col>
          <el-form-item label="提成备注">
            <el-input type="textarea" v-model="formData.commission_memo" :rows='4' placeholder="请在此处填写业务提成相关的备注"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
    	<el-button @click="dialogVisible = false" size="medium">取 消</el-button>
    	<el-button type="primary" size="medium" @click="handleSave">保 存</el-button>
    </div>
  </el-dialog>
</template>

<script>
  export default{
    data(){
      return{
        index:-1,
        formData:{
            ordercode:'',

        },
        dialogVisible:false
      }
    },
    methods:{
        init(index,data){
          this.index=index;
          this.formData=data;
        },
        handleSave(){
            const params={
              ouid:this.formData.ouid,
              commission_rmb:this.formData.commission_rmb,
              commission_status:this.formData.commission_status,
              commission_memo:this.formData.commission_memo
            }

            this.axios.post("api/admin/order/commission_update",params).then(res=>{
              console.log(res);
              if(res.status==200 && res.data.code==1){
                 this.$message({
                 	message: "保存成功!",
                 	showClose: true,
                 	type: 'success',
                 	duration: 1500
                 });
                 this.dialogVisible=false;
                 this.$emit("updated",this.index,params);
              }
            })

        }
    }
  }
</script>

<style>
</style>
